package com.zq.solr.config;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.solr.core.SolrOperations;
import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;

@Configuration
@EnableSolrRepositories
public class SolrConfig {
    private final static Logger logger = LoggerFactory.getLogger(SolrConfig.class);

    @Bean
    public SolrClient solrClient() {
        SolrClient solrClient = new HttpSolrClient("http://127.0.0.1:9081/solr/");
//        SolrClient solrClient = new CloudSolrClient();
        return solrClient;
    }

    @Bean
    public SolrOperations getSoleTemplate() {
        SolrTemplate solrTemplate = new SolrTemplate(this.solrClient());
//        solrTemplate.registerQueryParser(QueryParserBase.class,MyQueryParserBase);
        return solrTemplate;
    }
}
